echo -----------------------------------------
echo - Building SBC::COMA
echo -----------------------------------------

echo deleting target directory
rm -f -R deployment-units
mkdir deployment-units
echo created folder: deployment-units

echo performing install goal
echo .
echo .
echo building space-utils assembly
cd Space-Utils
mvn clean install
cd ..

echo .
echo building space-utils assembly
cd RMI-Utils
mvn clean install
cd ..

echo .
echo building space-utils assembly
cd Commons
mvn clean install
cd ..

echo .
echo building space-utils assembly
cd Assembly
mvn clean install
cd ..

echo .
echo building space-utils assembly
cd Load-Balancer
mvn clean install
cd ..

echo .
echo building space-utils assembly
cd Logistics
mvn clean install
cd ..

echo .
echo building space-utils assembly
cd Producer
mvn clean install
cd ..

echo .
echo building space-utils assembly
cd Tester
mvn clean install
cd ..







echo .
echo .
echo creating commons assembly
cd Commons
mvn package assembly:assembly
cd ..

echo .
echo .
echo creating producer assembly
cd Producer
mvn package assembly:assembly
cd ..

echo .
echo .
echo creating assembly worker assembly
cd Assembly
mvn package assembly:assembly
cd ..

echo .
echo .
echo creating tester worker assembly
cd Tester
mvn package assembly:assembly
cd ..

echo .
echo .
echo creating logistics worker assembly
cd Logistics
mvn package assembly:assembly
cd ..

echo .
echo .
echo creating load balancer assembly
cd Load-Balancer
mvn package assembly:assembly
cd ..

echo copying files to target directory
cp Commons/target/coma-commons-distribution.zip deployment-units
cp Producer/target/producer-distribution.zip deployment-units
cp Assembly/target/assembly-worker-distribution.zip deployment-units
cp Tester/target/tester-worker-distribution.zip deployment-units
cp Logistics/target/logistics-worker-distribution.zip deployment-units
cp Load-Balancer/target/load-balancer-distribution.zip deployment-units

cd deployment-units
unzip coma-commons-distribution.zip -d coma-commons-distribution
chmod +x coma-commons-distribution/spaceServer.sh
chmod +x coma-commons-distribution/rmiServer.sh
chmod +x coma-commons-distribution/spaceComputerCount.sh
chmod +x coma-commons-distribution/rmiComputerCount.sh

unzip producer-distribution.zip -d producer-distribution
chmod +x producer-distribution/spaceProducer.sh
chmod +x producer-distribution/rmiProducer.sh

unzip assembly-worker-distribution.zip -d assembly-worker-distribution
chmod +x assembly-worker-distribution/spaceAssemblyWorker.sh
chmod +x assembly-worker-distribution/rmiAssemblyWorker.sh

unzip tester-worker-distribution.zip -d tester-worker-distribution
chmod +x tester-worker-distribution/spaceTesterWorker.sh
chmod +x tester-worker-distribution/rmiTesterWorker.sh

unzip logistics-worker-distribution.zip -d logistics-worker-distribution
chmod +x logistics-worker-distribution/spaceLogisticsWorker.sh
chmod +x logistics-worker-distribution/rmiLogisticsWorker.sh

unzip load-balancer-distribution.zip -d load-balancer-distribution
chmod +x load-balancer-distribution/spaceLoadBalancer.sh
chmod +x load-balancer-distribution/rmiLoadBalancer.sh

cd ..

cp space-benchmark.sh deployment-units
chmod +x deployment-units/space-benchmark.sh

cp rmi-benchmark.sh deployment-units
chmod +x deployment-units/rmi-benchmark.sh


echo .
echo .
echo DONE - Created deployment units
